package net.zjitc.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by Administrator on 2017/9/25.
 */
@WebServlet(name = "HttpServletOne",urlPatterns = "/hservlet")
public class HttpServletOne extends HttpServlet {

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              /*  //设置响应的编码方式
                response.setCharacterEncoding("utf-8");
                //设置响应头，给浏览器用的（设置浏览器的编码方式）
                response.setHeader("Content-Type","text/html;charset=utf-8");*/

              //内部其实是两个部分设置了
                response.setContentType("text/html;charset=utf-8");

        //设置3秒后自动跳转
        //response.setHeader("refresh","3;http://www.zjitc.net");
        //刷新当前页面
       /* response.setHeader("refresh","3");*/

         //response.sendRedirect("/web/gServlet");
       //重定向到登录页面？？
        response.sendRedirect("/web/login/login.jsp");

   /*     PrintWriter out = response.getWriter();
        out.write("测试测试测试测试测试测试测试测试测试测试测试http get .....");
        out.write("测试http");*/
    }
}
